﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace hyjiacan.util.web.wp
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 绑定事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainForm_Load(object sender, EventArgs e)
        {
            ButtonEventHandler eh = new ButtonEventHandler(this);
            eh.BindClickEventOn(bPost)
                .BindClickEventOn(bCategory)
                .BindClickEventOn(bTag)
                .BindClickEventOn(bOption)
                .BindClickEventOn(bPage)
                .BindClickEventOn(bComment)
                .BindClickEventOn(bUser)
                .BindClickEventOn(bHelp)
                .BindClickEventOn(bAbout)
                
                .BindClickEventOn(bSettings);
        }

        /// <summary>
        /// 处理鼠标事件，响应此事件使可通过控件拖动窗体
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainForm_MouseDown(object sender, MouseEventArgs e)
        {
            NativeMethods.ReleaseCapture();
            NativeMethods.SendMessage(this.Handle, 0x0112, 0xF012, 0);
        }

        /// <summary>
        /// 关闭程序
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bExit_Click(object sender, EventArgs e)
        {
            ExitApplication();
        }

        /// <summary>
        /// 最小化窗体
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bMin_Click(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Minimized;
        }

        private void bHide_Click(object sender, EventArgs e)
        {
            this.Hide();
        }
        /// <summary>
        /// 点击托盘图标显示窗体
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tray_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                this.Show();
            }
        }

        /// <summary>
        /// 关闭程序
        /// </summary>
        void ExitApplication()
        {
            Application.Exit();
        }

        private void miShowWindow_Click(object sender, EventArgs e)
        {
            this.Show();
        }

        private void miExit_Click(object sender, EventArgs e)
        {
            ExitApplication();
        }

    }
}
